<include file=".:Common:header" />
<script language="javascript">
function editRole(){
	var row = $('#datagrid').datagrid('getSelected');
	if(!row.id) return;
	window.location.href = "{:U('Role/edit')}&id="+row.id;
}
function editRolePurview(){
	var row = $('#datagrid').datagrid('getSelected');
	if(!row.id) return;
	window.location.href = "{:U('Role/purview')}&id="+row.id;
}
function deleteRole(){
	var row = $('#datagrid').datagrid('getSelected');
	if (row){
		$.messager.confirm('提示', '确定删除该角色吗？', function(r){
			if (r){
				ajaxPost("{:U('Role/remove')}", {'id': row.id}, function(d){
					if(d.status == 0){
						alertText(d.info, 'error');
					}else{
						$('#datagrid').datagrid('reload');
					}
				});
			}else return false;
		});	
	}
}
$(function(){
	$('#datagrid').datagrid();
});
</script>
<div id="wrapper" class="wrapper clear">
	<div class="main">
    	<div class="toolbar">
			<a href="{:U('Role/add')}" id="addnewitem">新增角色</a>
            <a href="javascript:editRole();" id="edit">修改</a>
            <a href="javascript:editRolePurview();" id="edit">授权</a>
			<a href="javascript:deleteRole()" id="remove">删除角色</a>
		</div>
        <div class="table_wrap" style="margin-top:10px;">
        	<div class="table_list">	
				<table id="datagrid" width="100%" border="0" title="角色列表" url="{:U('system/Role/lst')}" pagination="true" striped="true" idField="id" singleSelect="true">
					<thead>
				        <tr>
				            <th field="id" width="50" sortable="true" checkbox="true">ID</th>
				            <th field="name" width="100" sortable="true">角色名称</th>
				            <th field="status" width="150" sortable="true" align="left">角色状态</th>
				            <th field="add_time" width="150" sortable="true" align="left">添加时间</th>
				            <th field="sort" width="50" sortable="true">排序</th>
				            <th field="remark" width="477">备注</th>
				        </tr>
				    </thead>
				</table>
			</div>
		</div>		
	</div>
</div>	

<include file=".:Common:footer" />